#include "abc-server-main-page-controller.h"

#include <sstream>
#include "util/net/http-response.h"
#include "util/html/template/factory.h"
#include "abc-server.h"

AbcServerMainPageController::AbcServerMainPageController(AbcServer &server)
    : server_(server) {
}

void AbcServerMainPageController::handleHttpRequest(const HttpRequest &request, HttpResponse &response) {
    const html::tmplt::Template *t = server_.httpTemplateFactory().byPath("main.html");
    if (!t) {
        return;
    }
    std::ostringstream ss;
    std::map<std::string, DynamicObj> objs;
    t->render(objs, ss);
    response.buffer() = ss.str();
}

